var mongoose = require("mongoose");
var DB_URL = "mongodb://localhost:27017/waimai";

mongoose.connect(DB_URL, { useNewUrlParser: true ,useUnifiedTopology:true});
//状态的监听
mongoose.connection.on("error", function (error) {
    console.log("数据库连接失败：" + error);
});
mongoose.connection.on("open", function () {
    console.log("------数据库连接成功！------");
});

//导出方便其他地方使用
module.exports = mongoose;